package cn.zzp.oneway;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

/**
 * @ClassName Producer
 * @Description
 * @Author 祝志鹏
 * @Date 2022/8/16 18:13
 */
public class Producer {

    public static void main(String[] args) throws Exception {

        DefaultMQProducer producer = new DefaultMQProducer("oneway_product_group");

        producer.setNamesrvAddr("localhost:9876");

        producer.start();

        Message message = new Message("oneway", "hello", "五十六个民族五十六只花五十六个兄弟姐妹是一家".getBytes(StandardCharsets.UTF_8));

        producer.sendOneway(message);

        // 如果不再发送消息，关闭Producer实例。
        producer.shutdown();
    }
}
